<?php
class TopicController extends Epic_Controller_Action 
{	
	/**
	 * Authentication
	 *
	 * @see Epic_Controller_Action::init()
	 * @return void;
	 */
	public function init()
	{
		if (Epic::getSession()->get('admin')==false)
			$this->_redirect(Epic::getUrl('admin/acc/login'));
	}
	public function listAction () {
		Epic::setTitle("List Topic");
		if (Epic::getSession()->get('admin')==false)
			$this->_redirect(Epic::getUrl('admin/acc/login'));
			
		Epic::addListJsUrl('admin/table/jquery.dataTables.min.js');
  		Epic::addListJsUrl('admin/table/table.js');
  		Epic::addListJsUrl('admin/ajax.js');
	}
	public function addTopicAction(){
		Epic::setTitle("Add Topic");
		if (Epic::getSession()->get('admin')==false)
			$this->_redirect(Epic::getUrl('admin/acc/login'));
		if($data=$this->getRequest()->getPost()){
			if($data["name"]==""){
				Epic::setError("Please enter name");
			
			}else{
				Epic::getModel("admin/topic")->save($data);
				Epic::setSuccess("Add Topic complete!");
				$this->_redirect(Epic::getUrl("admin/topic/list"));
			}
		}
	}
	
	public function viewTopicAction(){
		Epic::setTitle("view Topic");
		if(Epic::getSession()->get('admin'==false))
		$this->_redirect(Epic::getUrl('admin/acc/login'));
		
		Epic::addListJsUrl('admin/table/jquery.dataTables.min.js');
  		Epic::addListJsUrl('admin/table/table.js');
	}
	public function addPagerAction () {
		Epic::setTitle("Add Pager");
		if (Epic::getSession()->get('admin')==false)
			$this->_redirect(Epic::getUrl('admin/acc/login'));
			
  	}
}